Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Multi-part Upload #1232

Merged
merged 1 commit into from
Aug 24, 2015
Merged

Fix Multi-part Upload #1232

merged 1 commit into from
Aug 24, 2015

Conversation

etcimon
Copy link
Contributor

@etcimon etcimon commented Aug 24, 2015

The end of stream is not always --\r\n in forms, but the boundary is always followed by --

return stream.readLine(max_line_length) != "--";

enforce(stream.leastSize >= 2);
auto ub = stream.peek();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a good idea in general (leastSize could return just 1 even if the connection is still open and could yield more data, and peek is not required to return anything at all). But in this case it's possible to just use ubyte[2] ub; stream.read(ub); instead. It has to be either "--" or "\r\n". Both of them terminate the form part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me the peek returns [boundary]--, so maybe I should read the boundary + 2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't look right, since the boundary is already consumed above (lines 250/251 and 259). Maybe a peek bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that's a bug in the content-length reader I implemented on my fork.

The end of stream is not always `--\r\n` in forms, but the boundary is always followed by `--`

Use read and an array instead

Read only 2 bytes

Use nullSink instead of a new NullOutputStream

Use enforce
@s-ludwig
Copy link
Member

Looks good to me now! Merging in.

s-ludwig added a commit that referenced this pull request Aug 24, 2015
@s-ludwig s-ludwig merged commit 11623d5 into vibe-d:master Aug 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants